import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import router from '@/Router/config.js'



const imports = (path, folder = '/Main') => {
  if (path.indexOf('.vue') == -1) path += '/index.vue'
  return () => import('@/views' + folder + path)
}
// console.log(imports);

Vue.use(Router)


export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      children: [
        ...router.map(route => {
          return {
            path: route.path,
            name: route.name,
            component: imports(route.file),
            meta: {
              crumb: route.crumb
            }
          }
        })
      ]
    },
    {
      path: '/about',
      name: 'about',
      component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    },
    { // 博彩页面
      path: '/hilo',
      name: 'hilo',
      component: () => import(/* webpackChunkName: "about" */ './views/Hilo/index.vue')
    },
    { // 博彩页面
      path: '/Product',
      name: 'Product',
      component: () => import('./views/Product.vue')
    },
    { //未知页面
      path: '*', component: () => import('./views/NotFound.vue')
    }
  ]
})
